(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/module/chat/chat.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, 'd98c8xnSTxF25J5FwPAJnWt', 'chat', __filename);
// module/chat/chat.js

"use strict";

// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
var beiMiCommon = require("BeiMiCommon");
cc.Class({
    extends: beiMiCommon,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
        chatView: {
            default: null,
            type: cc.ScrollView
        },
        msgRow: {
            default: null,
            type: cc.Prefab
        },
        msgRowSelf: {
            default: null,
            type: cc.Prefab
        },
        msgInput: {
            default: null,
            type: cc.EditBox
        },
        totalCount: 0
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad: function onLoad() {
        // for(let i=0;i<this.totalCount;i++){
        //     var msgRow = cc.instantiate(this.msgRow);
        //     this.chatView.content.addChild(msgRow);
        // }


    },
    showChat: function showChat() {
        this.node.active = true;
        console.log("showChat");
    },
    hideChat: function hideChat() {
        this.node.active = false;
        console.log("hideChat");
    },
    sendMsg: function sendMsg() {
        var msg = this.msgInput.string;
        this.msgInput.string = "";
        var msgRow = cc.instantiate(this.msgRowSelf);
        var msgScript = msgRow.getComponent("msg");
        //设置聊天文字
        msgScript.msg_txt.string = msg;
        //设置昵称
        msgScript.nickname.string = cc.beimi.user.username;

        this.chatView.content.addChild(msgRow);
        var socket = this.socket();
        socket.emit("roomMsg", msg);
    },
    showMsg: function showMsg(data) {
        var msgRow = cc.instantiate(this.msgRow);
        var msgScript = msgRow.getComponent("msg");

        //设置聊天文字
        msgScript.msg_txt.string = data.roomMsg;
        //设置昵称
        msgScript.nickname.string = data.player.username;
        //设置聊天头像
        // msgScript.bg_head = 

        this.chatView.content.addChild(msgRow);
    },
    start: function start() {}
}

// update (dt) {},
);

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=chat.js.map
        